#!/bin/sh
mnt="/mnt"
kill_all() {
    PIDS=`fuser -m $1`
    if [ ! -z "$PIDS"  ];then
        for line in $PIDS
        do
            if [ "$line" -eq "1"  ]; then
                break
            fi
            kill -9 $line 
        done
    fi

}
foreachd(){
        for file in $mnt/*
        do
            if [ -d $file ]
            then
                kill_all $file 1>/dev/null 2>&1
                umount $file 2>&1
                rmdir $file
            fi
           
        done
}
countfile=0

for file in $mnt/*
do
    if [ -d $file ]
    then
        countfile=$countfile+1
        break;
    fi
done

if [ $countfile -eq 0 ]
then
    echo 0 > /sys/class/gpio/gpio24/value 
else
    foreachd $mnt
    echo 0 > /sys/class/gpio/gpio24/value 
fi
